package com.quasar.hpatient.presenter;

import com.quasar.hpatient.model.httpmodel.AnotherResult;
import com.quasar.hpatient.model.medicalmodel.TestRecordData;
import com.quasar.hpatient.model.requestmodel.RequestModel;
import com.quasar.hpatient.onInterface.AnotherResultListener;
import com.quasar.hpatient.onInterface.viewInterface.UiInterface;

/**
 * author : 许建宏
 * Date: 2017/11/2 0002
 * View:单日化验单初始化(获取网络)
 */

public class TestRecordInitPresenter {

    private RequestModel requestModel;
    private UiInterface<AnotherResult<TestRecordData>> uiInterface;

    public TestRecordInitPresenter(UiInterface<AnotherResult<TestRecordData>> uiInterface) {
        this.requestModel = new RequestModel();
        this.uiInterface = uiInterface;
    }
    public void PostTestRecordInit(String startTime){

        requestModel.TestRecordDataModel(startTime, new AnotherResultListener<AnotherResult<TestRecordData>>() {
            @Override
            public void onSuccess(AnotherResult<TestRecordData> data) {
                uiInterface.onViewSuccess(data);
            }

            @Override
            public void onError(String msg) {
                uiInterface.onViewError(msg);
            }

            @Override
            public void onRefreshUI() {
                uiInterface.onViewRefreshUI();
            }
        });

    }

    //获取下一次化验数据
    public void postNextDayInspection(String startTime){

        requestModel.NextDayInspectionData(startTime, new AnotherResultListener<AnotherResult<TestRecordData>>() {
            @Override
            public void onSuccess(AnotherResult<TestRecordData> data) {
                uiInterface.onViewSuccess(data);
            }

            @Override
            public void onError(String msg) {
                uiInterface.onViewError(msg);
            }

            @Override
            public void onRefreshUI() {
                uiInterface.onViewRefreshUI();
            }
        });
    }
    //获取上一次化验数据
    public void postLastDayInspection(String startTime){

        requestModel.LastDayInspectionData(startTime, new AnotherResultListener<AnotherResult<TestRecordData>>() {
            @Override
            public void onSuccess(AnotherResult<TestRecordData> data) {
                uiInterface.onViewSuccess(data);
            }

            @Override
            public void onError(String msg) {
                uiInterface.onViewError(msg);
            }

            @Override
            public void onRefreshUI() {
                uiInterface.onViewRefreshUI();
            }
        });
    }

}
